package com.dk.service.Impl;

import com.dk.mapper.TabRouteMapper;
import com.dk.pojo.TabRoute;
import com.dk.service.RouteService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RouteServiceImpl implements RouteService {
    @Autowired
    TabRouteMapper tabRouteMapper;
    @Autowired
    RedisTemplate redisTemplate;
    @Override
    public List<TabRoute> getInfo() {
        return tabRouteMapper.selectByExample(null);
    }

    @Override
    public List<TabRoute> getInfoLimitSix() {
        return tabRouteMapper.getInfoLimitSix();
    }

    @Override
    public PageInfo<TabRoute> getInfoByCid(Integer pageNum, Integer pageSize, Integer cid) {
        PageHelper.startPage(pageNum,pageSize);
        List<TabRoute> routes = tabRouteMapper.getInfoByCid(cid);
        PageInfo<TabRoute> pageInfo = new PageInfo<>(routes);
        return pageInfo;
    }

    @Override
    public List<TabRoute> getRoutePopularRecommendation(Integer cid) {
        return tabRouteMapper.getRoutePopularRecommendation(cid);
    }

    @Override
    public TabRoute getInfoByRid(Integer rid) {
        return tabRouteMapper.selectByPrimaryKey(rid);
    }

    @Override
    public void updateRoute(TabRoute tabRoute) {
        tabRouteMapper.updateByPrimaryKeySelective(tabRoute);
    }

    @Override
    public PageInfo<TabRoute> getInfoRouteForFuzzyQuery(Integer pageNum, Integer pageSize, TabRoute tabRoute) {
        PageHelper.startPage(pageNum,pageSize);
        List<TabRoute> routes = tabRouteMapper.getInfoRouteForFuzzyQuery(tabRoute);
        PageInfo<TabRoute> pageInfo = new PageInfo<>(routes);
        return pageInfo;
    }

    @Override
    public List<TabRoute> getIsThemeRouteLimitFour() {
        return tabRouteMapper.getIsThemeRouteLimitFour();
    }

    @Override
    public List<TabRoute> getInfoOverseasTravelRoute() {
        return tabRouteMapper.getInfoOverseasTravelRoute();
    }

    @Override
    public List<TabRoute> getInfoLatestTravelRoute() {
        return tabRouteMapper.getInfoLatestTravelRoute();
    }

    @Override
    public List<TabRoute> getInfoRecommendationRouteTravel() {
        return tabRouteMapper.getInfoRecommendationRouteTravel();
    }
}
